// pages/myExamStack/examRecord/examRecord.js
var util = require('../../../utils/util.js');
const config = require('../../../utils/config');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    examRecordLists:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showLoading({
      title: '加载中...',
    })
    var that = this;
    wx.request({
      url: config.examUrl + '/exam-user-history',
      data: {
        userId: 2
      },
      method: 'GET',
      header: {
        'content-type': 'application/json'
      },
      success: function(res) {
        console.log( res.data);
        wx.hideLoading();
        var examRecordLists = res.data;
        if(examRecordLists != null){
          for(var i=0; i<examRecordLists.length; i++){
            if( examRecordLists[i].submitTime !=null){
              examRecordLists[i].submitTime = util.formatTimeTwo(examRecordLists[i].submitTime,'Y-M-D');
            } 
            if( examRecordLists[i].verifyTime !=null){
              examRecordLists[i].verifyTime = util.formatTimeTwo(examRecordLists[i].verifyTime,'Y-M-D');
            }
          }
          that.setData({
            examRecordLists: examRecordLists,
          })
        }
      },
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

})